package org.ice4apps.master.dao;

import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

/**
 * Client entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "client", catalog = "icemaster", uniqueConstraints = { @UniqueConstraint(columnNames = "client_key"),
                                                                    @UniqueConstraint(columnNames = "user_name") })
public class Client implements java.io.Serializable {
    // Fields
    private String       id;
    private String       userName;
    private String       clientKey;
    private String       password;
    private String       name;
    private Long         creationDate;
    private Long         renewalDate;
    private Long         nextRenewalDate;
    private Long         updationDate;
    private Set<Session> sessions = new HashSet<Session> (0);

    // Constructors
    /** default constructor */
    public Client () {
    }

    /** minimal constructor */
    public Client (String id,
                   String userName,
                   String clientKey,
                   String password,
                   String name,
                   Long creationDate,
                   Long renewalDate,
                   Long nextRenewalDate) {
        this.id = id;
        this.userName = userName;
        this.clientKey = clientKey;
        this.password = password;
        this.name = name;
        this.creationDate = creationDate;
        this.renewalDate = renewalDate;
        this.nextRenewalDate = nextRenewalDate;
    }

    /** full constructor */
    public Client (String id,
                   String userName,
                   String clientKey,
                   String password,
                   String name,
                   Long creationDate,
                   Long renewalDate,
                   Long nextRenewalDate,
                   Long updationDate,
                   Set<Session> sessions) {
        this.id = id;
        this.userName = userName;
        this.clientKey = clientKey;
        this.password = password;
        this.name = name;
        this.creationDate = creationDate;
        this.renewalDate = renewalDate;
        this.nextRenewalDate = nextRenewalDate;
        this.updationDate = updationDate;
        this.sessions = sessions;
    }

    // Property accessors
    @Id
    @Column(name = "id", unique = true, nullable = false, length = 36)
    public String getId () {
        return this.id;
    }

    public void setId (String id) {
        this.id = id;
    }

    @Column(name = "user_name", unique = true, nullable = false, length = 36)
    public String getUserName () {
        return this.userName;
    }

    public void setUserName (String userName) {
        this.userName = userName;
    }

    @Column(name = "client_key", unique = true, nullable = false, length = 36)
    public String getClientKey () {
        return this.clientKey;
    }

    public void setClientKey (String clientKey) {
        this.clientKey = clientKey;
    }

    @Column(name = "password", nullable = false, length = 36)
    public String getPassword () {
        return this.password;
    }

    public void setPassword (String password) {
        this.password = password;
    }

    @Column(name = "name", nullable = false, length = 36)
    public String getName () {
        return this.name;
    }

    public void setName (String name) {
        this.name = name;
    }

    @Column(name = "creation_date", nullable = false)
    public Long getCreationDate () {
        return this.creationDate;
    }

    public void setCreationDate (Long creationDate) {
        this.creationDate = creationDate;
    }

    @Column(name = "renewal_date", nullable = false)
    public Long getRenewalDate () {
        return this.renewalDate;
    }

    public void setRenewalDate (Long renewalDate) {
        this.renewalDate = renewalDate;
    }

    @Column(name = "next_renewal_date", nullable = false)
    public Long getNextRenewalDate () {
        return this.nextRenewalDate;
    }

    public void setNextRenewalDate (Long nextRenewalDate) {
        this.nextRenewalDate = nextRenewalDate;
    }

    @Column(name = "updation_date")
    public Long getUpdationDate () {
        return this.updationDate;
    }

    public void setUpdationDate (Long updationDate) {
        this.updationDate = updationDate;
    }

    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "client")
    public Set<Session> getSessions () {
        return this.sessions;
    }

    public void setSessions (Set<Session> sessions) {
        this.sessions = sessions;
    }
}